import Reflux from "reflux"
import GUtils from "@/utils";
import RsaHelper from "@/utils/encrypt";

const prefix = "/personal/"
const api = {
    resetPwd: prefix + "resetPwd",
}

const createAction = () => {
    const Action = Reflux.createActions({
        resetPwd: {asyncResult: true},
    });

    Action.resetPwd.listen(function (vo) {
        vo.oldPwd = RsaHelper.doEncrypt(vo.oldPwd);
        vo.newPwd = RsaHelper.doEncrypt(vo.newPwd);
        GUtils.Ajax.post(api.resetPwd, vo).then(this.completed, this.failed)
    })
    return Action;
};

export {api, createAction}